package com.itheima.stargraph.exception;

import cn.hutool.http.HttpStatus;
import com.itheima.stargraph.dto.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @Author mr.zhang
 * Date 2025/6/9 14:57
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler{

    @ExceptionHandler(value = Exception.class)
    public Result exceptionCatch(Exception e){
        log.error("出现异常,异常:",e);
        return Result.error(HttpStatus.HTTP_INTERNAL_ERROR,e.getMessage());
    }
}
